package collection;

import java.util.*;

public class SortInteger {
    public static void main(String[] args) {
        Random random = new Random();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(random.nextInt(100));
        }
        System.out.println("list:"+list);
        Collections.sort(list);

        //升序
        System.out.println("排序后list："+list);
        //反转
        Collections.reverse(list);
        System.out.println("反转后的list："+list);
        //对字符串集合进行排序
        List<String> list1 = new ArrayList<>();
        list1.add("tom");
        list1.add("black");
        list1.add("jack");
        list1.add("jerry");
        list1.add("Kobe");
        list1.add("rose");
        System.out.println("原始数据："+list1);
        //Comparator<String> comparator = Comparator.naturalOrder();
        //list1.sort(comparator);//[Kobe, black, jack, jerry, rose, tom]
        Collections.sort(list1);
        System.out.println("排序后的数据："+list1);
    }
}
